﻿using GameEditor.View;
using GameEditor.View.Components;
using PureMVC.Interfaces;
using PureMVC.Patterns;
using System.Windows;
using GameEngine.Model;
using GameEngine.Model.Data;
using GameEditor;
using System;
using GameEngine;

namespace GameEditor.Commands
{
    public class Page_ThingTypeEditorMenu_Action_Command<MyIdType> : SimpleCommand
        where MyIdType : IComparable<MyIdType>
    {
        override public void Execute(INotification notification)
        {
            var mediator = Facade.RetrieveMediator(GameEditorFacade.ThingTypeEditorMediatorName) as ThingTypePropertiesEditor_MenuMediator<MyIdType>;
            switch ((IThingTypeEditorMenuViewConstants.ButtonTags)notification.Body)
            {
                case IThingTypeEditorMenuViewConstants.ButtonTags.OK:
                    if (true)//TODO edit existing proxy
                    {
                        var vo = ModelFacade<MyIdType>.Instance.CreateThingTypeVO(
                            mediator.ThingTypeName,
                            ModelFacade<MyIdType>.Instance.ThingTypeTypes[mediator.SelectedType],
                            mediator.SelectedView);
                        var dataProxy = ModelFacade<MyIdType>.Instance.CreateThingTypeDataProxy(vo);
                        ModelFacade<MyIdType>.Instance.Game.AddThingType(dataProxy);
                    }
                    break;
                case IThingTypeEditorMenuViewConstants.ButtonTags.CANCEL:
                    break;
            }            
        }
    }
}
